package cn.huihe.demoai.controller;

import cn.huihe.demoai.common.Result;
import cn.huihe.demoai.common.SwaggerBearerAuth;
import cn.huihe.demoai.common.WebResponse;
import cn.huihe.demoai.vendor.stanford.BasicPipelineApi;
import cn.huihe.demoai.vendor.stanford.ExampleResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SwaggerBearerAuth
@RestController
@RequestMapping("/v1/nlp")
@Tag(name = "NLP API")
public class NLPController {

    private final BasicPipelineApi basicPipelineApi;

    public NLPController(BasicPipelineApi basicPipelineApi) {
        this.basicPipelineApi = basicPipelineApi;
    }

    @GetMapping("/basicpipeline/{sentenceN}")
    @Operation(
            summary = "basic pipeline example",
            responses = {@ApiResponse(responseCode = "200")},
            parameters = {
                    @Parameter(name = "sentenceN", description = "input Nth sentence")
            }
    )
    public ResponseEntity<Result<ExampleResponse>> example(@PathVariable Integer sentenceN) {
        return WebResponse.ok(basicPipelineApi.execute(sentenceN));
    }

}
